import Vue from 'vue'
import Vuex from 'vuex'
//import axios from 'axios'
Vue.use(Vuex)
const store = new Vuex.Store({
  state: {
	datas:{}
  },
  actions: {
	loadUserInfo({commit}){
		commit('SET_USER_DATA')
	},	
	loadUserInfo2({commit}){
		commit('SET_USER_DATA2')
	},
	loadTwoDayClasses({commit}){
		commit('LOAD_TWODAY_CLASSES')
	},	
	updateTwoDayClasses({commit}){
		commit('UPDATE_TWODAY_CLASSES')
	}
	  /*
    LOAD_PROJECT_LIST: function ({ commit }) {
      axios.get('http://localhost:8080/api/getData').then((response) => {
        commit('SET_PROJECT_LIST', { datalist: response.data.data.posts.data })
      }, (err) => {
        console.log(err)
      })
    },
	ADD_ITEM_ACTION:({commit}) => {
		commit('ADD_ITEM')
	}*/
  },
  mutations: {
	  updateMessage (state, message) {
    state.obj = message
  },
	 SET_CURRENT_NAV_INDEX(state, index){
		state.currentNav = parseInt(index)
	 },
	SET_USER_DATA(state,dataobj){
		 state.datas.user = {
			"userType": 2,
			"data": {
				"studentId": 1,
				"studentName": "小丁",
				"studentTel": "1111222",
				"studentPassword": "",
				"studentVipType": "vip/year",
				"studentSex": "女",
				"studentUsedTimes": null,
				"studentVipTime": "2018-06-01",
				"studentRestTimes": null,
				"studentRegisterTime": "2017-05-03",
				"placeId": 2,
				"maliceTimes": 0,
				"maliceRemoveTime": null
			}
		 }
		 state.datas.place = {
            "placeId": 2,
            "placeName": "聚万金",
            "placeAddress": "永州市商业街",
            "placeTel": "7000707",
            "placeManager": "李老板"
        }
	 },
	 SET_USER_DATA2(state,dataobj){
		 Vue.delete(state.datas, 'user')
		 state.datas.user = {
				"userType": 3,
				"data": {
					"studentId": 3,
					"studentName": "Hosou",
					"studentTel": "1111222",
					"studentPassword": "",
					"studentVipType": "vip/year",
					"studentSex": "女",
					"studentUsedTimes": null,
					"studentVipTime": "2018-06-01",
					"studentRestTimes": null,
					"studentRegisterTime": "2017-05-03",
					"placeId": 2,
					"maliceTimes": 0,
					"maliceRemoveTime": null
				}
		 }
	 },
	 LOAD_TWODAY_CLASSES(state,dataobj){
		 state.datas.classes=[
			{
				"day": "2017-08-07",
					"info" : [
						{
							"id": 1, 
							"date": "2017-08-07",
							"start_time": "06:50:00", 
							"end_time": "07:50:00", 
							"name":"晨练", 
							"teacher":"",
							"remark":"拜月式",
							"selected_num":0,
							"all_num": 18, 
							"place_name":"聚万金",
							"classrom":"常温",
							"tag_color":"#cab81f"
						},
						{
							"id": 2, 
							"date": "2017-08-07",
							"start_time": "09:30:00", 
							"end_time": "10:30:00", 
							"name":"", 
							"teacher":"",
							"remark":"",
							"selected_num":0,
							"all_num": 0, 
							"place_name":"",
							"classrom":"",
							"tag_color":""
						},
						{
							"id": 3, 
							"date": "2017-08-07",
							"start_time": "17:00:00", 
							"end_time": "18:00:00", 
							"name":"", 
							"teacher":"",
							"remark":"",
							"selected_num":0,
							"all_num": 0, 
							"place_name":"",
							"classrom":"",
							"tag_color":""
						},
						{
							"id": 4, 
							"date": "2017-08-07",
							"start_time": "18:30:00", 
							"end_time": "19:30:00", 
							"name":"王瑜伽Raja Yoga", 
							"teacher":"lina",
							"remark":"无",
							"selected_num":0,
							"all_num": 18, 
							"place_name":"聚万金",
							"classrom":"常温",
							"tag_color":"#cab81f"
						}
					]
			},
			{
				"day": "2017-08-08",
					"info" : [
						{
							"id": 5, 
							"date": "2017-08-08",
							"start_time": "06:50:00", 
							"end_time": "07:50:00", 
							"name":"晨练", 
							"teacher":"",
							"remark":"拜月式",
							"selected_num":0,
							"all_num": 18, 
							"place_name":"聚万金",
							"classrom":"常温",
							"tag_color":"#cab81f"
						},
						{
							"id": 6, 
							"date": "2017-08-08",
							"start_time": "09:30:00", 
							"end_time": "10:30:00", 
							"name":"", 
							"teacher":"",
							"remark":"",
							"selected_num":0,
							"all_num": 0, 
							"place_name":"",
							"classrom":"",
							"tag_color":""
						},
						{
							"id": 7, 
							"date": "2017-08-08",
							"start_time": "17:00:00", 
							"end_time": "18:00:00", 
							"name":"", 
							"teacher":"",
							"remark":"",
							"selected_num":0,
							"all_num": 0, 
							"place_name":"",
							"classrom":"",
							"tag_color":""
						},
						{
							"id": 8, 
							"date": "2017-08-08",
							"start_time": "18:30:00", 
							"end_time": "19:30:00", 
							"name":"哈他瑜伽", 
							"teacher":"王老师",
							"remark":"无",
							"selected_num":0,
							"all_num": 18, 
							"place_name":"聚万金",
							"classrom":"常温",
							"tag_color":"#cab81f"
						}
					]
			}
		]
	},
	 UPDATE_TWODAY_CLASSES(state,dataobj){
		 state.datas.classes = [
			{
				"day": "--------------",
					"info" : [
						{
							"id": 1, 
							"date": "2017-08-07",
							"start_time": "06:50:00", 
							"end_time": "07:50:00", 
							"name":"晨练", 
							"teacher":"",
							"remark":"拜月式",
							"selected_num":0,
							"all_num": 18, 
							"place_name":"聚万金",
							"classrom":"常温",
							"tag_color":"#cab81f"
						},
						{
							"id": 2, 
							"date": "2017-08-07",
							"start_time": "09:30:00", 
							"end_time": "10:30:00", 
							"name":"", 
							"teacher":"",
							"remark":"",
							"selected_num":0,
							"all_num": 0, 
							"place_name":"",
							"classrom":"",
							"tag_color":""
						},
						{
							"id": 3, 
							"date": "2017-08-07",
							"start_time": "17:00:00", 
							"end_time": "18:00:00", 
							"name":"", 
							"teacher":"",
							"remark":"",
							"selected_num":0,
							"all_num": 0, 
							"place_name":"",
							"classrom":"",
							"tag_color":""
						},
						{
							"id": 4, 
							"date": "2017-08-07",
							"start_time": "18:30:00", 
							"end_time": "19:30:00", 
							"name":"王瑜伽Raja Yoga", 
							"teacher":"lina",
							"remark":"无",
							"selected_num":0,
							"all_num": 18, 
							"place_name":"聚万金",
							"classrom":"常温",
							"tag_color":"#cab81f"
						}
					]
			},
			{
				"day": "2017-08-08",
					"info" : [
						{
							"id": 5, 
							"date": "2017-08-08",
							"start_time": "06:50:00", 
							"end_time": "07:50:00", 
							"name":"晨练", 
							"teacher":"",
							"remark":"拜月式",
							"selected_num":0,
							"all_num": 18, 
							"place_name":"聚万金",
							"classrom":"常温",
							"tag_color":"#cab81f"
						},
						{
							"id": 6, 
							"date": "2017-08-08",
							"start_time": "09:30:00", 
							"end_time": "10:30:00", 
							"name":"", 
							"teacher":"",
							"remark":"",
							"selected_num":0,
							"all_num": 0, 
							"place_name":"",
							"classrom":"",
							"tag_color":""
						},
						{
							"id": 7, 
							"date": "2017-08-08",
							"start_time": "17:00:00", 
							"end_time": "18:00:00", 
							"name":"", 
							"teacher":"",
							"remark":"",
							"selected_num":0,
							"all_num": 0, 
							"place_name":"",
							"classrom":"",
							"tag_color":""
						},
						{
							"id": 8, 
							"date": "2017-08-08",
							"start_time": "18:30:00", 
							"end_time": "19:30:00", 
							"name":"哈他瑜伽", 
							"teacher":"王老师",
							"remark":"无",
							"selected_num":0,
							"all_num": 18, 
							"place_name":"聚万金",
							"classrom":"常温",
							"tag_color":"#cab81f"
						}
					]
			}
		]
	}
	 
	  /*
    SET_PROJECT_LIST: (state, { datalist }) => {
      state.datas = datalist
    },
	ADD_ITEM: (state) => {
	  state.datas.push({
                "id": 111,
                "title": "1111111111111",
                "source": "今日头条",
                "publish": "2016-11-18",
                "images": ["http://www.test.com/img/p1.jpg"]
            })
	}*/
  },
  getters: {
    userType: state => {
      return state.datas.user.userType
      //return state.obj
    }
  }
})
export default store